
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
request.setAttribute("decorator", "none");
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);
%>

<%-- 导入面包屑 --%>
<jsp:include page="../common/nav.jsp"></jsp:include>

<div class="wrapper wrapper-content animated fadeInRight">

	<%-- 导入提示信息框 --%>
    <c:if test="${hint!=null&&hint!=''}">
   		<jsp:include page="../common/alert/alert.jsp">
   			<jsp:param value="${hint}" name="alertType"/>
   			<jsp:param value="${alertMessage}" name="alertMessage"/>
   		</jsp:include>
    </c:if>

	<div class="row">
		<div class="col-lg-12">
			<div class="ibox ">
				<div class="ibox-title btn-success btn-outline panel-success collapse-link" title="展开/收起">
					<h5>工作流配置</h5>
					<div class="ibox-tools">
						<i class="fa fa-chevron-up"></i> 
					</div>
				</div>

				<div class="ibox-content border-bottom" style="padding-bottom: 0px;">
					<form id="form" action="web/cuxWorkflowConfHead/editCuxWorkflowConfHead" method="post">
						<div class="form-group  row">
							<label class="col-sm-2 col-form-label"><span class="text-danger">*</span><strong>工作流编码</strong></label>
							<div class="col-sm-4">
								<input id="confHeadCode" name="confHeadCode" type="text" class="form-control" value="${requestScope.cuxWorkflowConfHead.confHeadCode}">
							</div>
							
							<label class="col-sm-2 col-form-label"><span class="text-danger">*</span><strong>工作流名称</strong></label>
							<div class="col-sm-4">
								<input id="workflowName" name="workflowName" type="text" class="form-control" value="${requestScope.cuxWorkflowConfHead.workflowName}">
							</div>
						</div>
						<div class="hr-line-dashed"></div>
						
						<div class="form-group  row">
							<label class="col-sm-2 col-form-label"><strong>工作流描述</strong></label>
							<div class="col-sm-10">
								<textarea id="workflowDesc" name="workflowDesc" type="text" class="form-control">${requestScope.cuxWorkflowConfHead.workflowDesc}</textarea>
							</div>
						</div>
						<div class="hr-line-dashed"></div>
						
						<div class="form-group  row">
							<label class="col-sm-2 col-form-label"><strong>业务类型</strong></label>
							<div class="col-sm-4">
								<select class="chosen-select form-control" name="businessType" id="businessType">
		                        	<option value="" selected="selected">请选择...</option>
		                        	<c:forEach items="${requestScope.workflowBusinessTypeMap}" var="workflowBusinessType">
		                        		<option value="${workflowBusinessType.key}">${workflowBusinessType.value}</option>
		                        	</c:forEach>
		                        </select>
		                        <span class="help-block m-b-none" style="color: silver;">根据业务类型判断单据应该执行的工作流</span>
							</div>
							
							<label class="col-sm-2 col-form-label"><strong>状态</strong></label>
	                        <div class="col-sm-4">
		                        <select class="form-control" name="status" id="status">
		                            <option value="Y">已生效</option>
		                            <option value="N" selected="selected">未生效</option>
		                        </select>
	                        </div>
						</div>
						<div class="hr-line-dashed"></div>
						
						<div class="form-group row">
							<div class="col-sm-12 col-sm-offset-2 text-right">
								<button class="btn btn-white btn-lg" type="button" onclick="window.location.href='web/cuxWorkflowConfHead/getCuxWorkflowConfHeadList'">返回</button>&nbsp;
								<button class="ladda-button ladda-button-demo btn btn-success btn-lg" data-style="expand-right">&nbsp;&nbsp;保存&nbsp;&nbsp;<i class="fa fa-save"></i></button>
							</div>
						</div>
						
						<input type="hidden" id="confHeadId" name="confHeadId" value="${requestScope.cuxWorkflowConfHead.confHeadId}">
						<input type="hidden" name="createdDate" value="${requestScope.cuxWorkflowConfHead.createdDate}">
						<input type="hidden" name="createdBy" value="${requestScope.cuxWorkflowConfHead.createdBy}">
					</form>
				</div>

				<!-- tab 开始 -->
				<div class="row">
					<div class="col-lg-12">
						<div class="ibox ">
							<div class="ibox-title btn-info btn-outline panel-info">
								<h5>工作流配置行</h5>
								<div class="ibox-tools">
								</div>
							</div>

							<div class="ibox-content border-bottom" style="padding-bottom: 0px;">
								<div class="tabs-container">
									<ul class="nav nav-tabs">
										<li><a class="nav-link active" data-toggle="tab" href="#ctab" onclick="getLineTab('${requestScope.cuxWorkflowConfHead.confHeadCode}')">行信息</a></li>
									</ul>
									<div id="tabDiv" class="tab-content">
									</div>
								</div>
							</div>
							
						</div>
					</div>
				</div>
				<!-- tab 结束 -->
				
			</div>
		</div>
	</div>
</div>

<!-- select2 -->
<script src="js/plugins/select2/select2.full.min.js"></script>

<script>
	$(document).ready(function() {
		//初始化status
		if("${requestScope.cuxWorkflowConfHead.status}"!=""){
			$("#status").val("${requestScope.cuxWorkflowConfHead.status}");
		}
		//初始化businessType
		if("${requestScope.cuxWorkflowConfHead.businessType}"!=""){
			$("#businessType").val("${requestScope.cuxWorkflowConfHead.businessType}");
		}
		//初始化confHeadCode只读
		if("${requestScope.cuxWorkflowConfHead.confHeadCode}"!=""){
			$("#confHeadCode").prop("readonly", true);
		}
	
		//初始化select2
		$('.select2').select2({width: "100%"});
		
		
		//表单提交
		var l = $('.ladda-button-demo').ladda();

		l.click(function() {
			$("#form").valid();
			//l.ladda('stop');
		});

		$("#form").validate({
			rules : {
				confHeadCode : {
					required : true,
					isCode : true,
				},
				workflowName : {
					required : true,
				},
				status : {
					required : true,
				},
			},
			submitHandler: function(form) {
				l.ladda('start');
		        form.submit();
		    }
		});
		
		//初始化tab
		getLineTab("${requestScope.cuxWorkflowConfHead.confHeadCode}");
	});
	
	
	//获取行tab
	function getLineTab(code){
		$.ajax({
			type: "post",
			url: "web/cuxWorkflowConfLine/getCuxWorkflowConfLineList",
			data: {"confHeadCode": code},
			async: false,
			dataType: "html",
			cache: false,
			success: function(data){
				if(data!=""){
					$("#tabDiv").html(data);
					$("#ctab").addClass("active");
					//隐藏保存按钮
					if($("#confHeadId").val()==null||$("#confHeadId").val()==""){
						$("#tabDiv .btn:not(.btn-redragon-adjust)").hide();
					}
					initControlAuth();
				}
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){
				redragonJS.alert(textStatus);
			}
		});
	}
	
</script>